package org.lex.elec.apps.cad;

import java.awt.BorderLayout;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;

import org.lex.elec.util.Restorable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ElecApplicationView extends JPanel implements Restorable {
	private static final long serialVersionUID = 2825648051209039299L;
	private final Logger log = LoggerFactory.getLogger(ElecApplicationView.class);
	private final ElecApp application;
	private JScrollPane scrollPane;
	private JTree tree;

	public ElecApplicationView(ElecApp application) {
		super();
		this.application = application;
		initialize();
	}

	private void initialize() {
		setLayout(new BorderLayout(0, 0));
		add(getScrollPane(), BorderLayout.CENTER);
	}

	// /////////////////
	// Restorable
	// /////////////////
	@Override
	public void store() {
		// FIXME
		log.info("store session");
	}

	@Override
	public void restore() {
		// FIXME
		log.info("restore session");
	}

	private JScrollPane getScrollPane() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setViewportView(getTree());
		}
		return scrollPane;
	}

	private JTree getTree() {
		if (tree == null) {
			tree = new JTree();
		}
		return tree;
	}
}
